package com.shijiwei.lifthelper.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.shijiwei.lifthelper.R;
import com.shijiwei.lifthelper.bean.CookData;
import com.squareup.picasso.Picasso;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

/**
 * Created by Administrator on 2015/12/16.
 */
public class CookCategoryAdapter extends AppBaseAdapter {
    public CookCategoryAdapter(List<CookData> list, Context context) {
        super(list, context);
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder ;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.item_listview_cook_category,parent,false);
            holder = new ViewHolder(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.categoryImage.setImageResource(R.mipmap.umeng_socialize_share_pic);
        final CookData data = (CookData) list.get(position);
        //x.image().bind(holder.categoryImage,data.getAlbums());
        Picasso.with(context).load(data.getAlbums()).into(holder.categoryImage);
        holder.nameText.setText(data.getTitle());
        holder.tlText.setText(data.getBurden());
        holder.xqText.setText("\u3000\u3000"+data.getImtro());
        return convertView;
    }

    private class ViewHolder extends BaseViewHolder{

        @ViewInject(R.id.iv_item_cook_category)
        private ImageView categoryImage;
        @ViewInject(R.id.tv_item_cook_name)
        private TextView nameText;
        @ViewInject(R.id.tv_item_cook_tl)
        private TextView tlText;
        @ViewInject(R.id.tv_item_cook_xq)
        private TextView xqText;

        public ViewHolder(View convertView) {
            super(convertView);
            x.view().inject(this,convertView);
        }
    }
}
